package com.hisense.ovcloud.warehouse;

import com.mybatisflex.core.query.QueryWrapper;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.reactive.config.EnableWebFlux;

@SpringBootApplication
@EnableWebFlux
@EnableAsync
@EnableEncryptableProperties
@EnableTransactionManagement
@ComponentScan(basePackages = {"com.hisense.ovcloud.*", "com.hisense.ovcloud.commons.configs.*", "com.hisense.ovcloud.warehouse.*"})
@MapperScan("com.hisense.ovcloud.warehouse.mapper")
@OpenAPIDefinition(info = @Info(title = "ac-julink-wareouse", version = "1.0", description = "Documentation ac-julink-warehouse APIs v1.0"))
public class Main implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Override
    public void run(String... args){

    }

    @Bean
    @Primary
    public Validator springValidator() {
        return new LocalValidatorFactoryBean();
    }

    @Bean
    @Primary
    public QueryWrapper queryWrapper(){
        return QueryWrapper.create();
    }
}
